package com.gio.tools.modules.dsp.dao;

import org.apache.ibatis.annotations.Select;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

public interface TableDao {

    /**
     * 获取数据表名列表
     * @return
     */
    @Select("select relname from pg_class where relkind = 'r' and relname not like 'pg_%' and relname not like 'sql_%' order by relname")
    List<String> findTableNameList();
    /**
     * 获取表结构
     * @param tableName
     * @return
     */
    @Select("SELECT column_name, data_type, ordinal_position, is_nullable FROM information_schema.\"columns\" WHERE \"table_name\"=#{tableName}")
    List<LinkedHashMap<String, Object>> findTableStructure(String tableName);

    /**
     * 获取表数据
     * @param tableName
     * @return
     */
    @Select("select * from ${tableName}")
    List<LinkedHashMap<String, Object>> findData(String tableName);

}
